package com.dragon.repository.mapper;

import com.dragon.repository.entity.SchedulingOutSon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 外发子表 Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-12-06
 */
@Mapper
public interface SchedulingOutSonMapper extends BaseMapper<SchedulingOutSon> {

    @Select("select dsos.*, dvp.`name` as productName, dp.name as produceName" +
            ", dpp.num as contractNum, ddd.name as unitName, dvp.material as VproductMaterial, dvp.remark as VproductRemark  from dragon_scheduling_out_son dsos " +
            "left join dragon_vendor_products dvp on dsos.product_id = dvp.id " +
            "left join dragon_produce dp on dsos.produce_id = dp.id " +
            "LEFT JOIN dragon_produce_products dpp on dpp.produce_id = dsos.produce_id and dpp.quotes_product_id = dsos.product_id " +
            "LEFT JOIN dragon_dictsort_detail ddd ON ddd.code_type = 'unitCode' AND dvp.unit = ddd.id " +
            "where dsos.scheduling_out_id = #{outId}")
    List<SchedulingOutSon> selectListByOutId(Integer outId);
}
